package com.zz.common.codeGenerator.controller;

import com.zz.common.base.dto.PageListResultDto;
import com.zz.common.base.dto.ResponseDTO;
import com.zz.common.base.dto.ResultDto;
import com.zz.common.codeGenerator.dto.GenTableColumnDto;
import com.zz.common.codeGenerator.service.GenTableColumnService;
import com.zz.common.constants.ApiConstants;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 代码生成业务表字段 服务接口类
 *
 * @author zhang.lei
 * @since 2025-08-18 20:32:36
 */
@Api(tags = "代码生成业务表字段服务接口类")
@RestController
@RequestMapping("code-generator/v1.0/gen-table-column")
public class GenTableColumnController {

    @Resource
    private GenTableColumnService genTableColumnService;

    @RequestMapping(value = "/query-with-page", method = RequestMethod.POST)
    @ApiOperation(value = "代码生成业务表字段-分页查询", notes = "传入分页信息")
    public PageListResultDto<GenTableColumnDto> queryWithPage(@RequestBody GenTableColumnDto genTableColumnDto) {
        PageListResultDto<GenTableColumnDto> res;
        res = genTableColumnService.queryWithPage(genTableColumnDto, genTableColumnDto.getQueryParam());
        res.setCode(ApiConstants.RESULT_SUCCESS);
        res.setMessage(ApiConstants.MESSAGE_SUCCESS);
        return res;
    }

    @RequestMapping(value = "/query-with-no-page", method = RequestMethod.POST)
    @ApiOperation(value = "代码生成业务表字段-不分页查询", notes = "传入查询条件信息")
    public ResponseDTO<List<GenTableColumnDto>> queryWithNoPage(@RequestBody GenTableColumnDto genTableColumnDto) {
        ResponseDTO<List<GenTableColumnDto>> res = new ResponseDTO<>();
        res.setData(genTableColumnService.queryWithNoPage(genTableColumnDto));
        res.setCode(ApiConstants.RESULT_SUCCESS);
        res.setMessage(ApiConstants.MESSAGE_SUCCESS);
        return res;
    }

    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    @ApiOperation(value = "代码生成业务表字段-查询ById", notes = "传入id")
    public ResponseDTO<GenTableColumnDto> queryById(@PathVariable("id") String id) {
        ResponseDTO<GenTableColumnDto> res = new ResponseDTO<>();
        GenTableColumnDto result = genTableColumnService.queryById(id);
        res.setData(result);
        return res;
    }

    @RequestMapping(value = "/query-by-ids", method = RequestMethod.POST)
    @ApiOperation(value = "代码生成业务表字段-查询ByIds", notes = "传入ids")
    public ResponseDTO<List<GenTableColumnDto>> queryByIds(@RequestBody List<String> ids) {
        ResponseDTO<List<GenTableColumnDto>> res = new ResponseDTO<>();
        res.setData(genTableColumnService.queryByIds(ids));
        res.setCode(ApiConstants.RESULT_SUCCESS);
        res.setMessage(ApiConstants.MESSAGE_SUCCESS);
        return res;
    }

    @RequestMapping(value = "/save", method = RequestMethod.POST)
    @ApiOperation(value = "代码生成业务表字段-创建", notes = "创建")
    public ResultDto save(@RequestBody GenTableColumnDto genTableColumnDto) {
        ResultDto res = new ResultDto();
        genTableColumnService.save(genTableColumnDto);
        res.setCode(ApiConstants.RESULT_SUCCESS);
        res.setMessage(ApiConstants.MESSAGE_SUCCESS);
        return res;
    }

    @RequestMapping(value = "/save-batch", method = RequestMethod.POST)
    @ApiOperation(value = "代码生成业务表字段-创建", notes = "创建")
    public ResultDto saveBatch(@RequestBody List<GenTableColumnDto> genTableColumnDtos) {
        ResultDto res = new ResultDto();
        genTableColumnService.saveBatch(genTableColumnDtos);
        res.setCode(ApiConstants.RESULT_SUCCESS);
        res.setMessage(ApiConstants.MESSAGE_SUCCESS);
        return res;
    }

    @RequestMapping(value = "/modify", method = RequestMethod.POST)
    @ApiOperation(value = "代码生成业务表字段-修改", notes = "修改")
    public ResultDto modify(@RequestBody GenTableColumnDto genTableColumnDto) {
        ResultDto res = new ResultDto();
        genTableColumnService.modify(genTableColumnDto);
        res.setCode(ApiConstants.RESULT_SUCCESS);
        res.setMessage(ApiConstants.MESSAGE_SUCCESS);
        return res;
    }

    @RequestMapping(value = "/modify-batch", method = RequestMethod.POST)
    @ApiOperation(value = "代码生成业务表字段-修改", notes = "修改")
    public ResultDto modifyBatch(@RequestBody List<GenTableColumnDto> genTableColumnDtos) {
        ResultDto res = new ResultDto();
        genTableColumnService.modifyBatch(genTableColumnDtos);
        res.setCode(ApiConstants.RESULT_SUCCESS);
        res.setMessage(ApiConstants.MESSAGE_SUCCESS);
        return res;
    }

    @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
    @ApiOperation(value = "代码生成业务表字段-删除ById", notes = "传入id")
    public ResultDto delete(@PathVariable("id") String id) {
        ResultDto res = new ResultDto();
        genTableColumnService.delete(id);
        res.setCode(ApiConstants.RESULT_SUCCESS);
        res.setMessage(ApiConstants.MESSAGE_SUCCESS);
        return res;
    }

    @RequestMapping(value = "/delete-batch", method = RequestMethod.POST)
    @ApiOperation(value = "代码生成业务表字段-批量删除", notes = "传入id")
    public ResultDto deleteBatch(@RequestBody List<String> ids) {
        ResultDto res = new ResultDto();
        genTableColumnService.deleteBatch(ids);
        res.setCode(ApiConstants.RESULT_SUCCESS);
        res.setMessage(ApiConstants.MESSAGE_SUCCESS);
        return res;
    }

}